import Vue from "vue";
import Vuex from "vuex";
//引入模块化文件
import { User } from "./modules/user";
import { getters } from "./getters";
import { Cart } from "./modules/cart";
import { Address } from "./modules/address";
import createPersistedState from "vuex-persistedstate";

Vue.use(Vuex);

export default new Vuex.Store({
  //状态数据持久化存储到localStorage
  plugins: [
    createPersistedState({
      storage: window.localStorage,  //存储到localStorage中
      key: "store",
    }),
  ],

  //集成模块化文件
  modules: {
    User,
    Cart,
    Address,
  },
  getters,
});
